'''
@author: Zhouhong Gu
@date: 2021/12/28
'''

import os


class PathVar:
    def __init__(self, input_data_path='./input_data', output_data_path='./output_data'):

        self.input_data_path = input_data_path
        self.original_excel = os.path.join(input_data_path, 'original_data.xlsx')
        self.covid_csv = os.path.join(input_data_path, 'covid19.csv')
        self.template_csv = os.path.join(input_data_path, 'template_file.csv')

        self.output_data_path = output_data_path

        for dirr in [input_data_path, output_data_path]:
            if not os.path.exists(dirr):
                os.mkdir(dirr)
        self.init_resultTwo_path()

    def init_resultTwo_path(self):
        self.resultTwoPath = os.path.join(self.output_data_path,'resultTwo')
        if not os.path.exists(self.resultTwoPath):
            os.mkdir(self.resultTwoPath)
        self.resultTwoExcel = os.path.join(self.resultTwoPath,'result_two.xls')
        self.resultTwoFinal = os.path.join(self.resultTwoPath,'result_two_to_honglin.xls')
        self.resultTwoParameters = os.path.join(self.resultTwoPath,'result_two_parameters.txt')

class parametersNvariables:
    def __init__(self):
        self.range_parameters = self.init_range_parameters()
        self.start_parameters = self.init_start_parameters()
        self.start_variables = self.init_start_variables()

    def init_range_parameters(self):
        range_parameters = {}
        range_parameters['I_loss_rate'] = 0.8
        range_parameters['A_loss_rate'] = 0.15
        range_parameters['R_loss_rate'] = 1 - range_parameters['I_loss_rate'] - range_parameters['A_loss_rate']

        range_parameters['E_ratio'] = 0.01
        range_parameters['Ehq_ratio'] = 0.01
        range_parameters['Ecq_ratio'] = 0.01
        range_parameters['t_1'] = 4
        range_parameters['t_2'] = 5

        range_parameters['q_1_min'] = 0.00000001
        range_parameters['q_1_max'] = 1

        range_parameters['q_2_min'] = 0.00000001
        range_parameters['q_2_max'] = 1

        range_parameters['q_3_min'] = 0.00000001
        range_parameters['q_3_max'] = 1

        range_parameters['p_1_min'] = 0.00000001
        range_parameters['p_1_max'] = 1

        range_parameters['p_2_min'] = 0.00000001
        range_parameters['p_2_max'] = 1

        range_parameters['p_3_min'] = 0.00000001
        range_parameters['p_3_max'] = 1

        range_parameters['beta_1_min'] = 0.00000001
        range_parameters['beta_1_max'] = 1

        range_parameters['beta_2_min'] = 0.00000001
        range_parameters['beta_2_max'] = 1

        range_parameters['beta_3_min'] = 0.00000001
        range_parameters['beta_3_max'] = 1

        range_parameters['Lambda_min'] = 1/14 - 0.00000001
        range_parameters['Lambda_max'] = 1/14 + 0.00000001

        range_parameters['eposilon_min'] = 0.00000001
        range_parameters['eposilon_max'] = 1

        range_parameters['theta_min'] = 0.00000001
        range_parameters['theta_max'] = 1

        range_parameters['alpha_min'] = 0.00000001
        range_parameters['alpha_max'] = 1

        range_parameters['eta_min'] = 0.00000001
        range_parameters['eta_max'] = 1

        range_parameters['gamma_min'] = 0.00000001
        range_parameters['gamma_max'] = 1

        range_parameters['Q_min'] = 0.00000001
        range_parameters['Q_max'] = 1

        range_parameters['convegence_file'] = 'result.png'
        range_parameters['predict_range'] = 50

        return range_parameters

    def init_start_variables(self):
        start_variables = dict()
        start_variables['s'] = 600
        start_variables['sq'] = 0
        start_variables['e'] = 17
        start_variables['ehq'] = 3
        start_variables['ecq'] = 3
        start_variables['i'] = 0
        start_variables['a'] = 0
        start_variables['r'] = 0
        return start_variables

    def init_start_parameters(self):
        start_parameters = dict()
        start_parameters['q_1'] = 0.01
        start_parameters['q_2'] = 0.4
        start_parameters['q_3'] = 0.99
        start_parameters['t_1'] = 4
        start_parameters['t_2'] = 5
        start_parameters['p_1'] = 0.99  # 管控率
        start_parameters['p_2'] = 0.6  # 管控率
        start_parameters['p_3'] = 0.01  # 管控率
        start_parameters['Lambda'] = 0  # 隔离解除率
        start_parameters['beta_1'] = 0  # 感染者接触数——后面考虑建一个一次方程
        start_parameters['beta_2'] = 0  # 感染者接触数——后面考虑建一个一次方程
        start_parameters['beta_3'] = 0  # 感染者接触数——后面考虑建一个一次方程
        start_parameters['eposilon'] = 0  # 潜伏期传染力系数
        start_parameters['theta'] = 0  # 无症状感染者传染力系数
        start_parameters['alpha'] = 0  # 隔离率
        start_parameters['eta'] = 0  # 感染者中确诊患者比例
        start_parameters['gamma'] = 0  # 感染者移出率
        start_parameters['Q'] = 0  # 每天隔离人数
        return start_parameters



